package cn.lj.dao;

import cn.lj.domain.Product;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface IProductDao {

    //根据id查询订单
    @Select("select * from product where id=#{id}")
    public Product findById(@Param("id") int id);

    //查询所有的订单信息
    @Select("select * from product")
    public List<Product> findAll() throws Exception;

    //插入一条订单信息
    @Insert("insert into product(productNum,productName,cityName,departureTime,productPrice,productDesc,productStatus) values(#{productNum},#{productName},#{cityName},#{departureTime},#{productPrice},#{productDesc},#{productStatus})")
    void save(Product product);


    //删除一条订单信息
    @Delete ("delete  from product where id = #{id}")
    public void delProduct(@Param("id") int id);


//    @Update ("update product set productNum=#{productNum},productName=#{productName},productTypeId=#{productTypeId},cityName=#{cityName}," +
//            "productionTime=#{productionTime},productPrice=#{productPrice},productDesc=#{productDesc},productStatus=#{productStatus} where id = #{id}")
//    @Update("update product set productNum=#{productNum},productName=#{productName},cityName=#{cityName},DepartureTime=#{DepartureTime},productPrice=#{productPrice},productDesc=#{productDesc},productStatus=#{productStatus} where id = #{id};")
    //根据id修改订单信息
    @Update ("update product set productNum=#{productNum},productName=#{productName},cityName=#{cityName},DepartureTime=#{DepartureTime},productPrice=#{productPrice},productDesc=#{productDesc},productStatus=#{productStatus} where id = #{id}")
    void update(Product product);

    //根据productName模糊查询
//    @Select("Select * from product where productName like '%${productName}%' ")
    @Select ("select * from product where productName like #{productName}")
    List<Product> findAllByName(String productName);
}
